﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="KhachHang.aspx.cs" Inherits="ThemKhachHang" %>

 <asp:Content ID="Content1" ContentPlaceHolderID="Menu" Runat="Server">
<li ><a href="Default.aspx">Trang Chủ</a></li>
    <li><a href="Sach.aspx">Sách</a></li>
    <li><a href="Ebook.aspx">Ebook</a></li>
    <li ><a href="HoaDon.aspx">Hóa Đơn</a></li>
    <li  id="currect"><a href="KhachHang.aspx">Khách Hàng</a></li>
    <li><a href="WebService.aspx">Webservice</a></li>
    <li><a href="LienHe.aspx">Liên Hệ</a></li>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentTitle" Runat="Server">    
    QUẢN LÝ KHÁCH HÀNG
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="ContentDescription" Runat="Server">    
     Hệ thống khách hàng đăng ký sử dụng WS của nhà xuất bảng...
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContain" Runat="Server">
    <br/>
<br/>
<h4>Thêm khách hàng sử dụng WS</h4>
<hr />

    <asp:DetailsView ID="DetailsView1" runat="server" 
        DataSourceID="SqlDataSourceThemKhachHang" Height="50px" Width="317px" 
        AutoGenerateRows="False" DataKeyNames="MaKhachHang" DefaultMode="Insert" 
        BorderStyle="Solid" onitemcreated="DetailsView1_ItemCreated" 
        oniteminserted="DetailsView1_ItemInserted">
        <Fields>
            <asp:BoundField DataField="MaKhachHang" HeaderText="Mã Khách Hàng" 
                InsertVisible="False" ReadOnly="True" SortExpression="MaKhachHang" />
            <asp:BoundField DataField="TenTaiKhoan" HeaderText="Tên Tài Khoản" 
                SortExpression="TenTaiKhoan" />
            <asp:BoundField DataField="MatKhau" HeaderText="Mật Khẩu" 
                SortExpression="MatKhau" />
            <asp:BoundField DataField="DiaChiWeb" HeaderText="Địa Chỉ Web" 
                SortExpression="DiaChiWeb" />
            <asp:BoundField DataField="DiaChi" HeaderText="Địa Chỉ Liên Hệ" 
                SortExpression="DiaChi" />
            <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
            <asp:BoundField DataField="SoDienThoai" HeaderText="Số Điện Thoại" 
                SortExpression="SoDienThoai" />
            <asp:CommandField ShowInsertButton="True" InsertText="[ Thêm ] " CancelText=" [ Hủy ]" />
        </Fields>
    </asp:DetailsView>
    <asp:SqlDataSource ID="SqlDataSourceThemKhachHang" runat="server" 
        ConnectionString="<%$ ConnectionStrings:PublisherDBConnectionString %>" 
        DeleteCommand="DELETE FROM [KhachHang] WHERE [MaKhachHang] = @MaKhachHang" 
        InsertCommand="INSERT INTO [KhachHang] ([TenTaiKhoan], [MatKhau], [DiaChiWeb], [DiaChi], [Email], [SoDienThoai]) VALUES (@TenTaiKhoan, @MatKhau, @DiaChiWeb, @DiaChi, @Email, @SoDienThoai)" 
        SelectCommand="SELECT * FROM [KhachHang]" 
        UpdateCommand="UPDATE [KhachHang] SET [TenTaiKhoan] = @TenTaiKhoan, [MatKhau] = @MatKhau, [DiaChiWeb] = @DiaChiWeb, [DiaChi] = @DiaChi, [Email] = @Email, [SoDienThoai] = @SoDienThoai WHERE [MaKhachHang] = @MaKhachHang">
        <DeleteParameters>
            <asp:Parameter Name="MaKhachHang" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="TenTaiKhoan" Type="String" />
            <asp:Parameter Name="MatKhau" Type="String" />
            <asp:Parameter Name="DiaChiWeb" Type="String" />
            <asp:Parameter Name="DiaChi" Type="String" />
            <asp:Parameter Name="Email" Type="String" />
            <asp:Parameter Name="SoDienThoai" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="TenTaiKhoan" Type="String" />
            <asp:Parameter Name="MatKhau" Type="String" />
            <asp:Parameter Name="DiaChiWeb" Type="String" />
            <asp:Parameter Name="DiaChi" Type="String" />
            <asp:Parameter Name="Email" Type="String" />
            <asp:Parameter Name="SoDienThoai" Type="String" />
            <asp:Parameter Name="MaKhachHang" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>

<h4>Danh sách các khách hàng</h4>
<hr />
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="MaKhachHang" DataSourceID="SqlDataSourceDanhSachKhachHang" 
        Width="1005px" BorderStyle="Solid" BorderWidth="3px" BackColor="#CCCCCC" 
        BorderColor="#999999" CellPadding="4" CellSpacing="2" ForeColor="Black">
        <Columns>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" DeleteText="[Xóa]"  EditText="[Sửa]" HeaderText="Thao Tác"/>
            <asp:BoundField DataField="MaKhachHang" HeaderText="Mã Khách Hàng" 
                InsertVisible="False" ReadOnly="True" SortExpression="MaKhachHang" />
            <asp:BoundField DataField="TenTaiKhoan" HeaderText="Tên Khách Hàng" 
                SortExpression="TenTaiKhoan" />
            <asp:BoundField DataField="MatKhau" HeaderText="Mật Khẩu"  
                SortExpression="MatKhau" />
            <asp:BoundField DataField="DiaChiWeb" HeaderText="Địa Chỉ Web" 
                SortExpression="DiaChiWeb" />            
            <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
            <asp:BoundField DataField="SoDienThoai" HeaderText="Số Điện Thoại" 
                SortExpression="SoDienThoai" />
        </Columns>
        <FooterStyle BackColor="#CCCCCC" />
        <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
        <RowStyle BackColor="White" BorderStyle="Solid" BorderWidth="1px" />
        <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
        <SortedAscendingCellStyle BackColor="#F1F1F1" />
        <SortedAscendingHeaderStyle BackColor="#808080" />
        <SortedDescendingCellStyle BackColor="#CAC9C9" />
        <SortedDescendingHeaderStyle BackColor="#383838" />
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSourceDanhSachKhachHang" runat="server" 
        ConnectionString="<%$ ConnectionStrings:PublisherDBConnectionString %>" 
        DeleteCommand="DELETE FROM [KhachHang] WHERE [MaKhachHang] = @MaKhachHang" 
        InsertCommand="INSERT INTO [KhachHang] ([TenTaiKhoan], [MatKhau], [DiaChiWeb], [DiaChi], [Email], [SoDienThoai]) VALUES (@TenTaiKhoan, @MatKhau, @DiaChiWeb, @DiaChi, @Email, @SoDienThoai)" 
        SelectCommand="SELECT * FROM [KhachHang]" 
        UpdateCommand="UPDATE [KhachHang] SET [TenTaiKhoan] = @TenTaiKhoan, [MatKhau] = @MatKhau, [DiaChiWeb] = @DiaChiWeb, [DiaChi] = @DiaChi, [Email] = @Email, [SoDienThoai] = @SoDienThoai WHERE [MaKhachHang] = @MaKhachHang">
        <DeleteParameters>
            <asp:Parameter Name="MaKhachHang" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="TenTaiKhoan" Type="String" />
            <asp:Parameter Name="MatKhau" Type="String" />
            <asp:Parameter Name="DiaChiWeb" Type="String" />
            <asp:Parameter Name="DiaChi" Type="String" />
            <asp:Parameter Name="Email" Type="String" />
            <asp:Parameter Name="SoDienThoai" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="TenTaiKhoan" Type="String" />
            <asp:Parameter Name="MatKhau" Type="String" />
            <asp:Parameter Name="DiaChiWeb" Type="String" />
            <asp:Parameter Name="DiaChi" Type="String" />
            <asp:Parameter Name="Email" Type="String" />
            <asp:Parameter Name="SoDienThoai" Type="String" />
            <asp:Parameter Name="MaKhachHang" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
</asp:Content>

